﻿@model LeadMaster.Models.PurchaseOrders

@{
    ViewBag.Title = "Edit";
}

<style type="text/css">
.text-box
{
 width: 80px;   
}
</style>
<br />
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <div style="margin-left: 20px">
        <legend>@Model.Lead.Company.Company @Model.Lead.Sector.Sector : @Model.PID @if (Model.Paid??false==true)
                                                                            {
                                                                                @:Call Centre has been Paid for this campaign.
                                                                            }
                                                                            @if (Model.terminated??false==true)
                                                                            {
                                                                                @:The Order has been Terminated.
                                                                            }                                                                            
        </legend>
        @Html.HiddenFor(model => model.PurchaseOrderID)
        @Html.HiddenFor(model => model.LeadID)
        @Html.HiddenFor(model => model.Accepted)
        @Html.HiddenFor(model => model.Rejected)
        @Html.HiddenFor(model => model.Replaced)
        @Html.HiddenFor(model => model.Deficit)
        @Html.HiddenFor(model => model.InvalidReturns)
        @Html.HiddenFor(model => model.TotalLeadsSupplied)
        @Html.HiddenFor(model => model.terminated)
        <table style="width: 700px">
        <thead>
        <tr>
        <th>@Html.LabelFor(model => model.PID)</th>
        <th>@Html.LabelFor(model => model.WeekNo)</th>
        <th>@Html.LabelFor(model => model.WeekBeginning)</th>
        <th>@Html.LabelFor(model => model.WeekEnding)</th>
        <th>@Html.LabelFor(model => model.Quantity)</th>
        <th>@Html.LabelFor(model => model.SalesInvoiceNumber)</th>
        </tr>
        </thead>
        <tr>
        <td>@Html.EditorFor(model => model.PID )
            @Html.ValidationMessageFor(model => model.PID)</td>
        <td>@Html.EditorFor(model => model.WeekNo)
            @Html.ValidationMessageFor(model => model.WeekNo)</td>
        <td>
        @Html.TextBoxFor(model => model.WeekBeginning, new { @class="podates" })
        </td>
        <td>
        @Html.TextBoxFor(model => model.WeekEnding, new { @class = "podates" })
        </td>
        <td>@Html.EditorFor(model => model.Quantity)
            @Html.ValidationMessageFor(model => model.Quantity)</td>
        <td>@Html.EditorFor(model => model.SalesInvoiceNumber)
            @Html.ValidationMessageFor(model => model.SalesInvoiceNumber)</td>
        </tr>
        </table>
        <div class="spacer"></div>
        <table style="width: 700px">
        <thead>
        <tr>
        <th>
            @Html.LabelFor(model => model.PricePerLead)            
        </th>
        <th>
            @Html.LabelFor(model => model.FeePerInstall)            
        </th>
        <th>
            @Html.LabelFor(model => model.ClientPaid)
        </th>
        <th>
            @Html.LabelFor(model => model.Visible)
        </th>
        </tr>
        </thead>
        <tr>
        <td>
            £@Html.EditorFor(model => model.PricePerLead)
            @Html.ValidationMessageFor(model => model.PricePerLead)
        </td>
        <td>
            £@Html.EditorFor(model => model.FeePerInstall)
            @Html.ValidationMessageFor(model => model.FeePerInstall)
        </td>
        <td>
            @Html.EditorFor(model => model.ClientPaid)
            @Html.ValidationMessageFor(model => model.ClientPaid)
        </td>
        <td>
            @Html.EditorFor(model => model.Visible)
            @Html.ValidationMessageFor(model => model.Visible)
        </td>
        </tr>
        </table>
        <div class="spacer"></div>
        @if (Model.Lead.Combination == true)
        {
        <table>
        <thead>
        <tr>
        <th>@Html.LabelFor(m => m.Credits)</th>
        <th>@Html.LabelFor(m => m.CreditsPerGroup)</th>
        <th>@Html.LabelFor(m => m.CreditsComplete)</th>
        </tr>
        </thead>
        <tr>
        <td>
        @Html.EditorFor(model => model.Credits)
        @Html.ValidationMessageFor(model => model.Credits)
        </td>
        <td>
        @Html.EditorFor(model => model.CreditsPerGroup)
        @Html.ValidationMessageFor(model => model.CreditsPerGroup)
        </td>
        <td>
        @Html.EditorFor(model => model.CreditsComplete)
        @Html.ValidationMessageFor(model => model.CreditsComplete)
        </td>
        </tr>
        </table>
        }
        <div>
            @Html.LabelFor(model => model.Notes)
        </div>
        <div>
            @Html.TextAreaFor(model => model.Notes, new { @class="notes" })
            @Html.ValidationMessageFor(model => model.Notes)
        </div>
        <div class="spacer"></div>
        <div>
            @Html.LabelFor(model => model.CCNotes)
        </div>
        <div>
            @Html.TextAreaFor(model => model.CCNotes, new { @class="notes" })
            @Html.ValidationMessageFor(model => model.CCNotes)
        </div>
        <div class="spacer"></div>
        <p>
            <input type="submit" value="Save" class="bigsubmit"/>
        </p>
        </div>
    </fieldset>
}
<div class="spacer"></div>
<div>
    @Html.ActionLink("Back to List", "Index")
</div>


<script type="text/javascript">
    $(document).ready(function () {
        $("#CallCentreID").val("@(Model.CallCentreID)");
        $("#WeekBeginning").val($("#WeekBeginning").val().substring(0, 10))
        $("#WeekEnding").val($("#WeekEnding").val().substring(0, 10))

        $(".podates").datepicker({
            changeMonth: true,
            changeYear: true,
            regional: 'en-GB',
            dateFormat: 'dd/mm/yy'
        });

    });
</script>
